package com.base.llpark.utills;

import android.content.Context;

import com.base.commonlib.utils.DeteUtil;
import com.base.commonlib.utils.PrintUtil;
import com.base.llpark.bean.LlPark;


/**
 * Created by arvin on 2018/11/2.
 */

public class CrpuctPrintUtil {

    public static void printPark(Context context, final LlPark park, final String mCarType) {

        // TODO: 2018/12/15 联系电话
        PrintUtil.init(context, new PrintUtil.PrintRunnable() {
            @Override
            public void run() throws Exception {
                park.setCheckSignAddress(park.getCheckSignAddress().replace("_","-"));
                String createDate = park.getCheckDate();
                String year = createDate.substring(0, 4);
                String month = createDate.substring(5, 7);
                String day = createDate.substring(8, 10);
                String hours = createDate.substring(11, 13);
                String minutes = createDate.substring(14, 16);
                int[] normal = new int[]{PrintUtil.HIGHERX2};
                int[] normal_line = new int[]{PrintUtil.HIGHERX2, PrintUtil.UNDERLINE};
                PrintUtil.printText("\n\n\n\n", normal);
                PrintUtil.printText(park.getCompanyName()+"\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.ALIGNMIDDLE});
                PrintUtil.printText("不按规定停放车辆处理通知书\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.ALIGNMIDDLE});
                PrintUtil.printText("                         编号：", normal);
                PrintUtil.printText(park.getNoticeNo() + "\n", new int[]{PrintUtil.ALIGNRIGHT, PrintUtil.HIGHERX2});
                PrintUtil.printText("车牌号码: ", normal);
                PrintUtil.printText(park.getCarNo()+"     ", normal_line);
                PrintUtil.printText("车辆类型: ", normal);
                PrintUtil.printText(mCarType, normal_line);
                PrintUtil.printText("\n    您驾驶的机动车辆涉嫌于: ", normal);
                PrintUtil.printText(year + "年" + month + "月" + day + "日"+ hours + "时" + minutes + "分", normal_line);
                PrintUtil.printText("在", normal);
                PrintUtil.printText(park.getCheckSignAddress(), normal_line);
                PrintUtil.printText("不按规定停放机动车,已被拍照取证。", normal);
                PrintUtil.printText("\n    请您在七日内，携带本通知书，有效证件及复印件到", normal);
                PrintUtil.printText((park.getAddress()!=null?park.getAddress():""), normal_line);
                PrintUtil.printText("接受处理。", normal);
                PrintUtil.printText("联系电话："+park.getPhone()+"，如果您不方便到以上地址接受处理，可在车辆年审时到苏州市公安局车辆管理所接受处理。\n    受理时间：法定工作日内", normal);
                PrintUtil.printText("\n    执法人员:",normal);
                PrintUtil.printText(park.getUserName() + "," + park.getPersonName2(), normal_line);
                if (park.getCompanyName().length()>17)
                {
                    PrintUtil.printText("\n              " + park.getCompanyName() + "\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD});
                }else {
                    String str = "              ";
                    for (int i = 1; i <= (17 - park.getCompanyName().length()); i++) {
                        str += " ";
                    }
                    PrintUtil.printText("\n" + str + park.getCompanyName() + "\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD});
                }
//                PrintUtil.printText("\n"+str+ park.getCompanyName() + "\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD});
//                PrintUtil.printText("\n              " + park.getCompanyName(), new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD});
                PrintUtil.printText("\n                            "+year + "年" + month + "月" + day + "日",new int[]{PrintUtil.HIGHERX2,PrintUtil.BOLD});
                PrintUtil.printToBlackMark();

            }
        });
    }

    public static void printParkKS(Context context, final LlPark park, final String mCarType) {


        // TODO: 2018/12/15 联系电话
        PrintUtil.init(context, new PrintUtil.PrintRunnable() {
            @Override
            public void run() throws Exception {
                park.setCheckSignAddress(park.getCheckSignAddress().replace("_","-"));
                String createDate = park.getCheckDate();
                String year = createDate.substring(0, 4);
                String month = createDate.substring(5, 7);
                String day = createDate.substring(8, 10);
                String hours = createDate.substring(11, 13);
                String minutes = createDate.substring(14, 16);
                int[] normal = new int[]{PrintUtil.HIGHERX2};
                int[] normal_line = new int[]{PrintUtil.HIGHERX2, PrintUtil.UNDERLINE, PrintUtil.BOLD};
                Thread.sleep(1000);
                PrintUtil.printText("\n", normal);
                PrintUtil.printText(park.getCompanyName()+"\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.ALIGNMIDDLE});
                PrintUtil.printText("违法停车通知单\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD, PrintUtil.ALIGNMIDDLE});
                PrintUtil.printText("                       编号：", normal);
                PrintUtil.printText(park.getNoticeNo() + "\n", new int[]{PrintUtil.ALIGNRIGHT, PrintUtil.HIGHERX2});
                PrintUtil.printText("车牌号码: ", normal);
                PrintUtil.printText(park.getCarNo()+"", normal_line);
                PrintUtil.printText("          车辆类型: ", normal);
                PrintUtil.printText(mCarType+"\n", normal_line);
                PrintUtil.printText("违法停车时间: ", normal);
                PrintUtil.printText(year + "年" + month + "月" + day + "日" + hours + "时" + minutes + "分\n", normal_line);
                PrintUtil.printText("违法停车地点: ", normal);
                PrintUtil.printText(park.getCheckSignAddress()+"\n", normal_line);
                PrintUtil.printText("    该机动车在上述时间、地点停放，违反了《中华人民共和国道路交通安全法》第五十六条、《江苏省道路交通安全条例》第四十三条的规定，将被处以50元罚款。请于7日内携带本通知书、驾驶证、行驶证到 ", normal);
                PrintUtil.printText((park.getAddress()!=null?park.getAddress():""), normal_line);
                PrintUtil.printText(" 接受处理。", normal);
                PrintUtil.printText("    联系电话："+park.getPhone()+"\n", normal);
                PrintUtil.printText("    超过7日的请于法定工作日携带本通知书、驾驶证、行驶证到昆山市公安局交通警察大队公布的全市各交警中队违法处理窗口接受处理。",normal_line);
                if (park.getCompanyName().length()>17)
                {
                    PrintUtil.printText("\n              " + park.getCompanyName() + "\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD});
                }else {
                    String str = "              ";
                    for (int i = 1; i <= (17 - park.getCompanyName().length()); i++) {
                        str += " ";
                    }
                    PrintUtil.printText("\n" + str + park.getCompanyName() + "\n", new int[]{PrintUtil.HIGHERX2, PrintUtil.BOLD});
                }
//                if (park.getCompanyName().length()==17) {
//                    PrintUtil.printText("\n              " + park.getCompanyName() + "\n", normal);
//                }
                PrintUtil.printText("                       ", normal);
                PrintUtil.printText(DeteUtil.ToUpper(Integer.parseInt(year)) + "年" + DeteUtil.monthToUppder(Integer.parseInt(month)) + "月" + DeteUtil.dayToUppder(Integer.parseInt(day)) + "日\n",normal);
                PrintUtil.printText("执法人员:",normal);
                PrintUtil.printText(park.getUserName() + "  " + park.getPersonName2()+"\n", normal_line);
                PrintUtil.printText("   备注:机动车所有人登记的住所地址或者联系电话发生变化的，请及时向登记地车辆管理所申请变更备案。", new int[]{PrintUtil.HIGHERX01});
                PrintUtil.printToBlackMark();
            }
        });
    }









}
